﻿using System.Net;
using Blazor.CoffeeTalesApi.Dto;
using Blazor.CoffeeTalesApi.Entity;
using Blazor.Model.Dto;
using Blazor.Model.Entity;

namespace Blazor.Services.Update;

public interface IUpdateService
{
    Task<IPAddress?> FetchMyIpAsync();
    
    Task<ChannelInfo?> FetchChannelInfoAsync(Channel channel);
    
    Task<UpdateInfo?> FetchUpdateInfoAsync(Channel channel, uint version, string deviceId);

    Task<bool> SetNativeVersionAsync(Channel channel, uint latestVersion, uint minVersion);
    
    Task<bool> SetJumpUrlAsync(Channel channel, Uri uri);
    
    Task<bool> AddHotUpdateSettingAsync(Channel channel, uint nativeVersion, ResourceVersionEntry resourceVersion, string resourceUrl);
    Task<bool> DeleteHotUpdateSettingAsync(Channel channel, uint nativeVersion);
    
    Task<bool> SetResourceVersionAsync(Channel channel, uint nativeVersion, ResourceVersionEntry resourceVersion);
    
    Task<bool> SetResourceUrlAsync(Channel channel, uint nativeVersion, string url);
    
    Task<bool> AddWhitelistAsync(Channel channel, uint nativeVersion, IWhitelistKey key, ResourceVersionEntry resourceVersion);
    
    Task<bool> UpdateWhitelistAsync(Channel channel, uint nativeVersion, IWhitelistKey key, ResourceVersionEntry resourceVersion);
    
    Task<bool> RemoveWhitelistAsync(Channel channel, uint nativeVersion,  IWhitelistKey key);
    
    Task<bool> ClearWhitelistAsync(Channel channel, uint nativeVersion);
    
    Task<IDictionary<IWhitelistKey, ResourceVersionEntry>?> FetchWhitelistAsync(Channel channel, uint nativeVersion);
}